cmake_minimum_required(VERSION 3.17)
project(cpp_realsense)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
add_compile_options(/permissive-)

# change set(CMAKE_PREFIX_PATH "H:/Qt6/6.3.0/msvc2019_64/lib/cmake") to your own

set(CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX})
set(CMAKE_AUTOMOC ON)
find_package(Qt6 COMPONENTS Core REQUIRED)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()



add_definitions(-DHAVE_OPENCV_HIGHGUI -DHAVE_OPENCV_IMGPROC)
include_directories(include)
include_directories(include/librealsense2 include/opencv)
link_directories(lib)



# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(cv_msg REQUIRED)
find_package(pccmd_msg REQUIRED)




add_executable(${PROJECT_NAME} src/cpp_realsense.cpp)
ament_target_dependencies(${PROJECT_NAME}  
rclcpp  
cv_msg
)


add_executable(cvsub src/cvsub.cpp)
ament_target_dependencies(cvsub rclcpp cv_msg)


#add_executable(tcp_server src/tcp_server.cpp)
#ament_target_dependencies(tcp_server rclcpp pccmd_msg)


target_link_libraries(${PROJECT_NAME} realsense2 opencv_core346 opencv_highgui346 opencv_imgproc346 Qt6Core)


target_link_libraries(cvsub opencv_core346 opencv_highgui346 opencv_imgproc346 Qt6Core)

#target_link_libraries(tcp_server Qt6Core Qt6Network)




install(TARGETS
  cpp_realsense
  cvsub
  DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
